Skip to main content

Bug Tracker

Side navigation

Ticket #3539: queue[5917].diff
File queue[5917].diff, 8.5 KB (added by flesler, October 30, 2008 12:49AM UTC)
Index: Makefile
===================================================================
--- Makefile	(revision 5917)
+++ Makefile	(working copy)
@@ -9,6 +9,7 @@
 PLUG_DIR = ../plugins
 
 BASE_FILES = ${SRC_DIR}/core.js\
+	${SRC_DIR}/data.js\
 	${SRC_DIR}/selector.js\
 	${SRC_DIR}/event.js\
 	${SRC_DIR}/ajax.js\
Index: src/core.js
===================================================================
--- src/core.js	(revision 5917)
+++ src/core.js	(working copy)
@@ -457,31 +457,6 @@
 		return this.add( this.prevObject );
 	},
 
-	data: function( key, value ){
-		var parts = key.split(".");
-		parts[1] = parts[1] ? "." + parts[1] : "";
-
-		if ( value === undefined ) {
-			var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
-
-			if ( data === undefined && this.length )
-				data = jQuery.data( this[0], key );
-
-			return data === undefined && parts[1] ?
-				this.data( parts[0] ) :
-				data;
-		} else
-			return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
-				jQuery.data( this, key, value );
-			});
-	},
-
-	removeData: function( key ){
-		return this.each(function(){
-			jQuery.removeData( this, key );
-		});
-	},
-
 	domManip: function( args, table, reverse, callback ) {
 		var clone = this.length > 1, elems;
 
@@ -595,9 +570,8 @@
 	return target;
 };
 
-var expando = "jQuery" + now(), uuid = 0, windowData = {},
-	// exclude the following css properties to add px
-	exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+// exclude the following css properties to add px
+var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
 	// cache defaultView
 	defaultView = document.defaultView || {};
 
@@ -659,74 +633,6 @@
 		return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
 	},
 
-	cache: {},
-
-	data: function( elem, name, data ) {
-		elem = elem == window ?
-			windowData :
-			elem;
-
-		var id = elem[ expando ];
-
-		// Compute a unique ID for the element
-		if ( !id )
-			id = elem[ expando ] = ++uuid;
-
-		// Only generate the data cache if we're
-		// trying to access or manipulate it
-		if ( name && !jQuery.cache[ id ] )
-			jQuery.cache[ id ] = {};
-
-		// Prevent overriding the named cache with undefined values
-		if ( data !== undefined )
-			jQuery.cache[ id ][ name ] = data;
-
-		// Return the named cache data, or the ID for the element
-		return name ?
-			jQuery.cache[ id ][ name ] :
-			id;
-	},
-
-	removeData: function( elem, name ) {
-		elem = elem == window ?
-			windowData :
-			elem;
-
-		var id = elem[ expando ];
-
-		// If we want to remove a specific section of the element's data
-		if ( name ) {
-			if ( jQuery.cache[ id ] ) {
-				// Remove the section of cache data
-				delete jQuery.cache[ id ][ name ];
-
-				// If we've removed all the data, remove the element's cache
-				name = "";
-
-				for ( name in jQuery.cache[ id ] )
-					break;
-
-				if ( !name )
-					jQuery.removeData( elem );
-			}
-
-		// Otherwise, we want to remove all of the element's data
-		} else {
-			// Clean up the element expando
-			try {
-				delete elem[ expando ];
-			} catch(e){
-				// IE has trouble directly removing the expando
-				// but it's ok with using removeAttribute
-				if ( elem.removeAttribute )
-					elem.removeAttribute( expando );
-			}
-
-			// Completely remove the data cache
-			delete jQuery.cache[ id ];
-		}
-	},
-
 	// args is for internal usage only
 	each: function( object, callback, args ) {
 		var name, i = 0, length = object.length;
Index: src/data.js
===================================================================
--- src/data.js	(revision 0)
+++ src/data.js	(revision 0)
@@ -0,0 +1,136 @@
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+
+jQuery.extend({
+	cache: {},
+
+	data: function( elem, name, data ) {
+		elem = elem == window ?
+			windowData :
+			elem;
+
+		var id = elem[ expando ];
+
+		// Compute a unique ID for the element
+		if ( !id )
+			id = elem[ expando ] = ++uuid;
+
+		// Only generate the data cache if we're
+		// trying to access or manipulate it
+		if ( name && !jQuery.cache[ id ] )
+			jQuery.cache[ id ] = {};
+
+		// Prevent overriding the named cache with undefined values
+		if ( data !== undefined )
+			jQuery.cache[ id ][ name ] = data;
+
+		// Return the named cache data, or the ID for the element
+		return name ?
+			jQuery.cache[ id ][ name ] :
+			id;
+	},
+
+	removeData: function( elem, name ) {
+		elem = elem == window ?
+			windowData :
+			elem;
+
+		var id = elem[ expando ];
+
+		// If we want to remove a specific section of the element's data
+		if ( name ) {
+			if ( jQuery.cache[ id ] ) {
+				// Remove the section of cache data
+				delete jQuery.cache[ id ][ name ];
+
+				// If we've removed all the data, remove the element's cache
+				name = "";
+
+				for ( name in jQuery.cache[ id ] )
+					break;
+
+				if ( !name )
+					jQuery.removeData( elem );
+			}
+
+		// Otherwise, we want to remove all of the element's data
+		} else {
+			// Clean up the element expando
+			try {
+				delete elem[ expando ];
+			} catch(e){
+				// IE has trouble directly removing the expando
+				// but it's ok with using removeAttribute
+				if ( elem.removeAttribute )
+					elem.removeAttribute( expando );
+			}
+
+			// Completely remove the data cache
+			delete jQuery.cache[ id ];
+		}
+	},
+	queue: function( elem, type, data ) {
+		if ( elem ){
+	
+			type = (type || "fx") + "queue";
+	
+			var q = jQuery.data( elem, type );
+	
+			if ( !q || jQuery.isArray(data) )
+				q = jQuery.data( elem, type, jQuery.makeArray(data) );
+			else if( data )
+				q.push( data );
+	
+		}
+		return q;
+	},
+
+	dequeue: function( elem, type ){
+		return jQuery.queue( elem, type ).shift();
+	}
+});
+
+jQuery.fn.extend({
+	data: function( key, value ){
+		var parts = key.split(".");
+		parts[1] = parts[1] ? "." + parts[1] : "";
+
+		if ( value === undefined ) {
+			var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+			if ( data === undefined && this.length )
+				data = jQuery.data( this[0], key );
+
+			return data === undefined && parts[1] ?
+				this.data( parts[0] ) :
+				data;
+		} else
+			return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
+				jQuery.data( this, key, value );
+			});
+	},
+
+	removeData: function( key ){
+		return this.each(function(){
+			jQuery.removeData( this, key );
+		});
+	},
+	queue: function(type, data){
+		if ( typeof type != "string" ) {
+			data = type;
+			type = "fx";
+		}
+
+		if ( data === undefined )
+			return jQuery.queue( this[0], type );
+
+		return this.each(function(){
+			var queue = jQuery.queue( this, type, data );
+			
+			 if( type == "fx" && queue.length == 1 )
+				queue[0].call(this);
+		});
+	},
+	dequeue: function(type){
+		return jQuery.dequeue( this[0], type );
+	}
+});
Index: src/fx.js
===================================================================
--- src/fx.js	(revision 5917)
+++ src/fx.js	(working copy)
@@ -111,27 +111,17 @@
 		});
 	},
 
-	queue: function(type, fn){
-		if ( jQuery.isFunction(type) || jQuery.isArray(type) ) {
-			fn = type;
-			type = "fx";
-		}
-
-		if ( !type || (typeof type == "string" && !fn) )
-			return queue( this[0], type );
-
+	nextAnim:function(){
 		return this.each(function(){
-			if ( jQuery.isArray(fn) )
-				queue(this, type, fn);
-			else {
-				queue(this, type).push( fn );
-
-				if ( queue(this, type).length == 1 )
-					fn.call(this);
-			}
+			var queue = jQuery.queue( this );
+			
+			queue.shift()
+			
+			if( queue.length )
+				queue[0].call( this );
 		});
 	},
-
+	
 	stop: function(clearQueue, gotoEnd){
 		var timers = jQuery.timers;
 
@@ -151,7 +141,7 @@
 
 		// start the next in the queue if the last step wasn't forced
 		if (!gotoEnd)
-			this.dequeue();
+			this.nextAnim();
 
 		return this;
 	}
@@ -171,33 +161,6 @@
 	};
 });
 
-var queue = function( elem, type, array ) {
-	if ( elem ){
-
-		type = type || "fx";
-
-		var q = jQuery.data( elem, type + "queue" );
-
-		if ( !q || array )
-			q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
-
-	}
-	return q;
-};
-
-jQuery.fn.dequeue = function(type){
-	type = type || "fx";
-
-	return this.each(function(){
-		var q = queue(this, type);
-
-		q.shift();
-
-		if ( q.length )
-			q[0].call( this );
-	});
-};
-
 jQuery.extend({
 
 	speed: function(speed, easing, fn) {
@@ -215,7 +178,7 @@
 		opt.old = opt.complete;
 		opt.complete = function(){
 			if ( opt.queue !== false )
-				jQuery(this).dequeue();
+				jQuery(this).nextAnim();
 			if ( jQuery.isFunction( opt.old ) )
 				opt.old.call( this );
 		};

Download in other formats:

Original Format